<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script type="text/javascript" src="../js/vue.js"></script>
  <title>自定义指令</title>
</head>   
<body>
  <div id="root">
    <h2>自定义指令</h2>
    <hr>
    <button @click="number++">n++</button>
    <div v-bing="number"></div>
    <div v-fbnd="number"></div>
  </div>
  <script type="text/javascript">
    const vm = new Vue({
      el:'#root', 
      data:{
        name: 'Vue',
        number:1
      },
      directives:{
        bing:{
          bind(element,binding){
            console.log(element,binding);
            element.innerText = binding.value*100 
          },// 指令所在元素 与 Vue实例绑定时 调用
          inserted(element, binding){
            element.style.background = 'skyblue'
          },// 指令所在元素被插入页面时 调用
          update(element, binding){
            element.innerText = binding.value*100 
          }// 指令所在的模板被重新解析时 调用 
        },
        fbnd(element, binding){
          element.innerText = binding.value
        }
      },
      methods: {},
      computed: {}
    })
  </script>
</body>
</html>